package com.admin.mapper;

import com.admin.entity.Admin;
import com.admin.entity.Recharge;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;
import java.util.Map;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author marisheng
 * @since 2019-11-21
 */
public interface RechargeMapper extends BaseMapper<Recharge> {

    /**
     * 新增充值记录表
     * @return
     */
    @Insert("INSERT INTO admin_recharge (admin_recharge_sum , admin_recharge_admin , admin_recharge_time) VALUES (#{adminRechargeSum},#{adminRechargeAdmin},#{adminRechargeTime})")
    int insertseradmin_recharge(@Param("adminRechargeSum") int admin_money ,@Param("adminRechargeAdmin") int admin_id ,@Param("adminRechargeTime") String time );

    //沃币充值记录
    public List<Map> MoneyRechargeRecord(@Param("m") Map map);

    /**
     * 充值子用户
     * @param admin_id
     * @param admin_money
     * @return
     */
    @Update("update admin set admin_money=admin_money+#{admin_money} where admin_id=#{admin_id}")
    int updatemoneyById1(int admin_id , int admin_money);

    /**
     * 减少值的登录用户
     * @param admin_id
     * @param admin_money
     * @return
     */
    @Update("update admin set admin_money=admin_money-#{admin_money} where admin_id=#{admin_id}")
    int updatemoneyById2(int admin_id , int admin_money);

    @Select("select admin_money from admin where admin_id=#{adminId}")
    Admin selctAllMoney(@Param("adminId") Integer admin_id);

}
